#include "led.h"
#include "delay.h"
#include "sys.h"
#include "timer.h"
//当 led0pwmval 较大时，LED 会较亮。
int TIME_ON = 1000;  // 对应 PWM 占空比的最大值
int main(void)
{	
	u16 led0pwmval=0;
	u8 dir=1;	
	delay_init();	    	 //延时函数初始化
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);/*设置NVIC中断分组2:2位抢占优先级，2位响应优先级*/
	LED_Init();	//LED端口初始化		
	TIM3_PWM_Init(899,0);	 //不分频。PWM频率=72000000/900=80Khz
	while(1)
	{	delay_ms(10);	 
		if(dir)led0pwmval++;
		else led0pwmval--;
		if(led0pwmval>TIME_ON)dir=0;
		if(led0pwmval==0)dir=1;										 
		TIM_SetCompare2(TIM3,led0pwmval);//修改占空比，控制LED0的明暗	   
	}	 
}